package com.abhinav.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.env.Environment;

import com.abhinav.spring.bean.HelloWorld;
import com.abhinav.spring.bean.Profile;
import com.abhinav.spring.bean.PrototypeBean;
import com.abhinav.spring.bean.SingletonBean;
import com.abhinav.spring.bean.Student;
import com.abhinav.spring.bean.TextEditor;

public class App {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ApplicationContext ctx = new ClassPathXmlApplicationContext("SpringBeans.xml");

		// HelloWorld obj = (HelloWorld) ctx.getBean("helloBean");
		// obj.printHello();

		// Environment env = ctx.getEnvironment();

		// boolean containsFoo = env.containsProperty("foo");
		// System.out.println("Does my environment contain the 'foo' property? "
		// + containsFoo);

		 SingletonBean sBean = (SingletonBean) ctx.getBean("singletonBean");
		 System.out.println(sBean.getCount());
		 System.out.println(sBean.getPrototypeBean().getRandomNum());

//		 PrototypeBean pBean = (PrototypeBean) ctx.getBean("prototypeBean");
//		 System.out.println(pBean.getRandomNum());

		 SingletonBean sBean2 = (SingletonBean) ctx.getBean("singletonBean");
		 System.out.println(sBean2.getCount());
		 System.out.println(sBean2.getPrototypeBean().getRandomNum());

		// PrototypeBean pBean2 = (PrototypeBean) ctx.getBean("prototypeBean");
		// System.out.println(pBean2.getRandomNum());

		Student student = (Student) ctx.getBean("student");
		System.out.println(student.getName() + " " + student.getAge());

//		TextEditor te = (TextEditor) ctx.getBean("textEditor");
//		te.spellCheck();

//		Profile profile = (Profile) ctx.getBean("profile");
//		profile.printAge();
//		profile.printName();
	}

}
